package com.zhnc.dangjianpingtaiapp.argum;

import android.app.Activity;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.wangdh.utilslibrary.utils.logger.TLog;
import com.zhnc.dangjianpingtaiapp.R;
import com.zhnc.dangjianpingtaiapp.action.ActionUpdataInteface;
import com.zhnc.dangjianpingtaiapp.utils.recycler.RecyclerCommonAdapter;
import com.zhnc.dangjianpingtaiapp.utils.recycler.RecyclerViewHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wangdh
 * @time 2019/4/4 14:16
 * @describe
 */
public class ListDataHelp {
    public static ItemListRely getDW(final Activity activity, Object tag) {
        final ItemListRely itemListRely = new ItemListRely() {
            @Override
            public void requestData(final ActionUpdataInteface action) {
                super.requestData(action);
                new AsyncTask<Void, Void, Void>() {
                    @Override
                    protected Void doInBackground(Void... voids) {
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void aVoid) {
                        super.onPostExecute(aVoid);
                        final List<String> data = new ArrayList<>();
                        for (int i = 0; i < 60; i++) {
                            data.add("itme" + i);
                        }
                        action.updata(data);
                    }
                }.execute();
            }
        };
        itemListRely.setTitleName("最新动态");
        itemListRely.setMore("全部");
        itemListRely.setMoreClick(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TLog.e("点击了全部、，，，");
            }
        });

        RecyclerCommonAdapter<String> stringRecyclerCommonAdapter = new RecyclerCommonAdapter<String>(activity, R.layout.item_list, null) {
            @Override
            public void updataUI(RecyclerViewHolder recyclerViewHolder, String s) {
//                recyclerViewHolder.setText(R.id.itme_test_text, "更新" + s);
            }
        };

        itemListRely.setAdapter(stringRecyclerCommonAdapter);
        return itemListRely;
    }

    public static ItemListRely zhengwu3(final Activity activity, Object tag) {
        final ItemListRely itemListRely = new ItemListRely() {
            @Override
            public void requestData(final ActionUpdataInteface action) {
                super.requestData(action);
                new AsyncTask<Void, Void, Void>() {
                    @Override
                    protected Void doInBackground(Void... voids) {
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void aVoid) {
                        super.onPostExecute(aVoid);
                        final List<String> data = new ArrayList<>();
                        for (int i = 0; i < 2; i++) {
                            data.add("itme" + i);
                        }
                        action.updata(data);
                    }
                }.execute();
            }
        };
        itemListRely.setTitleName("政策法规");
        itemListRely.setMore("更多");

        RecyclerCommonAdapter<String> stringRecyclerCommonAdapter = new RecyclerCommonAdapter<String>(activity, R.layout.item_list, null) {
            @Override
            public void updataUI(RecyclerViewHolder recyclerViewHolder, String s) {
//                recyclerViewHolder.setText(R.id.itme_test_text, "更新" + s);
            }
        };
        itemListRely.setAdapter(stringRecyclerCommonAdapter);
        return itemListRely;
    }

    public static ItemListRely zhengwu4(final Activity activity, Object tag) {
        final ItemListRely itemListRely = new ItemListRely() {
            @Override
            public void requestData(final ActionUpdataInteface action) {
                super.requestData(action);
                new AsyncTask<Void, Void, Void>() {
                    @Override
                    protected Void doInBackground(Void... voids) {
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Void aVoid) {
                        super.onPostExecute(aVoid);
                        final List<String> data = new ArrayList<>();
                        for (int i = 0; i < 10; i++) {
                            data.add("itme" + i);
                        }
                        action.updata(data);
                    }
                }.execute();
            }
        };
        itemListRely.setTitleName("信息公开");
        itemListRely.setMore("更多");

        RecyclerCommonAdapter<String> stringRecyclerCommonAdapter = new RecyclerCommonAdapter<String>(activity, R.layout.item_list, null) {
            @Override
            public void updataUI(RecyclerViewHolder recyclerViewHolder, String s) {
//                recyclerViewHolder.setText(R.id.itme_test_text, "更新" + s);
            }
        };
        itemListRely.setAdapter(stringRecyclerCommonAdapter);
        return itemListRely;
    }

}
